home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / RDBLKAD.C < prev    next >
C/C++ Source or Header  |  1989-04-27  |  1KB  |  54 lines

  1. /*    rdblkad.c 4.4        */
  2.  
  3. /*F****************************************************************************
  4.  
  5. FUNCTION NAME:    rdblkad
  6.  
  7. ACTION:        Reads count characters from the A to D hardware
  8.         to an array of short.
  9.  
  10. PARAMETERS:
  11.         array:    pointer to an array of bytes that is filled with
  12.             the A to D data.
  13.         count:    number of bytes to read from the A to D ports.
  14.  
  15. RETURNS:    (void)
  16.  
  17. ******************************************************************************/
  18.  
  19. #define    ATODLINES    4    /* number of A to D conversion registers */
  20.  
  21. #include <hc11/io.h>
  22. #include <hc11/atod.h>
  23. #include <hc11/config.h>
  24. #include <hc11/directives.h>
  25.  
  26. SMALL
  27. void rdblkad(array, count)
  28.  
  29.     unsigned short    *array;        /* pointer to data to be read */
  30.     int        count;        /* number of bytes to be read */
  31.  
  32.     {
  33.  
  34.     unsigned short i;
  35.  
  36.     HC11.OPTION |= ADPU;
  37.  
  38.     while (count > 0)
  39.  
  40.         {
  41.  
  42.         HC11.ADCTL = HC11.ADCTL;    /* force conversion */
  43.  
  44.         while ((HC11.ADCTL & CCF) == 0)
  45.             ;        /* null statement */
  46.  
  47.         for (i=0;(i<ATODLINES) && (count>0);i++,count--)
  48.  
  49.             *(array++) = HC11.ADR[i];
  50.  
  51.         }    /* end of while count > 0 */
  52.  
  53.     }    /* end of rdblkad    */
  54.